#include <bits/stdc++.h>
using namespace std;

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--){
        int n,m,l,v,a[100005],b[100005],c[100005],d[100005],ans=0;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>a[i]>>b[i]>>c[i];
        }
        for(int i=1;i<=m;i++)
            cin>>d[i];
        for(int i=1;i<=n;i++)
            if(c[i]!=0) goto end;
        sort(d+1,d+m+1);
        for(int i=1;i<=n;i++){
            if(b[i]>v&&a[i]<=d[m]) ans++;
        }
        if(ans==0) cout<<ans<<' '<<m<<endl;
        else cout<<ans<<' '<<m-1<<endl;
        end:;
        for(int i=1;i<=n;i++)
            if(c[i]<=0) goto end1;
        sort(d+1,d+m+1);
        for(int i=1;i<=n;i++){
            if(a[i]<=d[m]){
                double h=sqrt(b[i]*b[i]+2*c[i]*(d[m]-a[i]));
                if(h>v) ans++;
            }
        }
        if(ans==0) cout<<ans<<' '<<m<<endl;
        else cout<<ans<<' '<<m-1<<endl;
        end1:;
    }
    return 0;
}
